from requests.cookies import RequestsCookieJar
import requests
# 1.制作cookie（三种方法）
#第一种，生成字典格式dict，# 或者直接写成字典格式
cookies1 = dict(cookies_are='working')
cookies2 = {"cookie_name": "cookie_value", }

#第二种，
cookie_jar = RequestsCookieJar
cookie_jar.set("BAIDUID", "4EDT7A5263775F7E0A4B&F330724:FG=1", domain="baidu.com")
requests.get('http://www.baidu.com',cookies = cookie_jar)
# 2.如果省事想用f12直接的登录cookie来用就可以这样操作
cookie = "anonymid=jk63khrk-y97r4p; _r01_=1; ln_uact=mr_mao_hacker@163.com; ln_hurl=http://hdn.xnimg.cn/photos/hdn421/20180720/1740/main_JAWQ_0aa000000ceb195a.jpg; _ga=GA1.2.273332130.1532825428; depovince=HUN; JSESSIONID=abcE5k0CiAJDc9ESVEcuw; ick_login=026ba348-e4e9-4871-9ce3-5868b95cfdd3; first_login_flag=1; loginfrom=syshome; wp_fold=0; BAIDU_SSP_lcr=https://www.baidu.com/link?url=VRx_HKUd53I5rYWZHvrQ9VVLotqST6-jtaZDlscFYCO&wd=&eqid=e957aec400037928000000065b64fcab; ick=64518f30-9a22-47df-b3c3-4114f185c3c6; t=8fcf47068763c279eea2620b51b7a3311; societyguester=8fcf47068763c279eea2620b51b7a3311; id=967272361; xnsid=fd736c63; jebecookies=3f9a3853-3371-4857-8268-308d663ca146|||||; jebe_key=19041c4e-4d38-4dc1-bfb9-124b81afae61%7C33b1d8f602cf6dd5a9834fe6f2bf97f2%7C1533346094265%7C1%7C1533346099750"
# 将上面哪个cookie转化成字典类型
cookie_dict = {i.split("=")[0]:i.split("=")[-1] for i in cookie.split("; ")}
print(cookie_dict)

# 2.获取cookie的方法，通过request请求获得cookie，并直接生成字典格式，获取其中的值
response.cookies.get_dict()